package com.zsy.dao;

import com.zsy.pojo.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ShoppingCartDao {

    ShoppingCart findUidAndDidOrSid(ShoppingCart shoppingCart);

    @Insert("insert into shopping_cart values(null,#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    void save(ShoppingCart shoppingCart);

    @Update("update shopping_cart set number=#{number} where id=#{id}")
    void update(ShoppingCart shoppingCartOne);

    @Select("select * from shopping_cart where user_id=#{userId}")
    List<ShoppingCart> list(Long userId);

    @Delete("Delete from shopping_cart where user_id=#{userId}")
    void clean(Long userId);


    @Select("select * from shopping_cart where dish_id=#{dishId} and user_id=#{userId}")
    ShoppingCart findByDishId(ShoppingCart shoppingCart);


    void reducedDishes( ShoppingCart shoppingCart);


    @Delete("delete from shopping_cart where dish_id=#{dishId} and user_id=#{userId}")
    void delete(ShoppingCart shoppingCart);


    ShoppingCart findByDishIdOrSid(ShoppingCart shoppingCart);
}
